Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ISSUE-#4567] Refactor nacos-client Load Logging Configuration code. #4572

Merged
merged 4 commits into from
Dec 26, 2020

Conversation

Maijh97
Copy link
Collaborator

@Maijh97 Maijh97 commented Dec 25, 2020

Please do not create a Pull Request without creating an issue first.

What is the purpose of the change

fix: #4567

Brief changelog

XX

Verifying this change

XXXX

Follow this checklist to help us incorporate your contribution quickly and easily:

  • Make sure there is a Github issue filed for the change (usually before you start working on it). Trivial changes like typos do not require a Github issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue.
  • Format the pull request title like [ISSUE #123] Fix UnknownException when host config not exist. Each commit in the pull request should have a meaningful subject line and body.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Write necessary unit-test to verify your logic correction, more mock a little better when cross module dependency exist. If the new feature or significant change is committed, please remember to add integration-test in test module.
  • Run mvn -B clean package apache-rat:check findbugs:findbugs -Dmaven.test.skip=true to make sure basic checks pass. Run mvn clean install -DskipITs to make sure unit-test pass. Run mvn clean test-compile failsafe:integration-test to make sure integration-test pass.

@Maijh97 Maijh97 requested a review from KomachiSion December 25, 2020 07:01
public static void loadConfiguration(AbstractNacosLogging logging) {
try {
if (logging != null) {
logging.loadConfiguration();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里要不要降级一下,自定义的失败了用默认的。

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可行

try {
logging.loadConfiguration();
} catch (Exception e) {
LOGGER.warn("Customize the {} load Configuration fail, message: {}", logging.getClass().getName(), e.getMessage());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOGGER.warn("Customize the {} load configuration fail, use default log configuration. Message: {}", logging.getClass().getName(), e.getMessage());

*/
public void loadConfiguration() {
try {
nacosLogging.loadConfiguration();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个变量感觉好绕啊。

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里是单例模式+策略模式的实现,对外其实只暴露了这一个方法,内部具体是logback还是log4j2是在初始化的时候决定的。

暂时没有开放完全拓展,主要是两个考虑, 一方面是nacos的日志主要是给运维人员排查用,不希望业务人员随意的改动nacos日志输出的级别和内容,另一方面日志框架其实并不太多,不会频繁扩展,适配起来难度不高。

将来如果需要完全拓展, 初始化加载的时候用个SPI就可以了。

@KomachiSion KomachiSion added this to the 1.4.1 milestone Dec 26, 2020
@KomachiSion KomachiSion merged commit a2ea808 into alibaba:develop Dec 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Nacos logs do not print to nacos logs file but print into users' application logs.
3 participants